Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compare tractograms (TODI, TDI, ACC) #767

Merged
merged 35 commits into from
Mar 20, 2024

Conversation

frheault
Copy link
Member

@frheault frheault commented Oct 23, 2023

Quick description

Scripts to compute differences between tractograms (or bundles)
2 big tractograms can be multi processed (2x2GB = 2h at 20 CPU)

It computes TODI+ACC, Correlation of TDI, voxel-wise distances of streamlines (using FSS)

4 outputs
out_acc.nii.gz: How does local orientations compare?
out_correlation.nii.gz How does the density of streamlines agrees?
out_diff.nii.gz How different is the shape of the streamlines?
out_heatmap.nii.gz Power means of 3 others?

Type of change

Check the relevant options.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Provide data, screenshots, command line to test (if relevant)

image

Checklist

  • My code follows the style guidelines of this project (run autopep8)
  • I added relevant citations to scripts, modules and functions docstrings and descriptions
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I moved all functions from the script file (except the argparser and main) to scilpy modules
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@pep8speaks
Copy link

pep8speaks commented Oct 23, 2023

Hello @frheault, Thank you for updating !

Line 648:80: E501 line too long (80 > 79 characters)

Line 11:80: E501 line too long (88 > 79 characters)

Line 41:80: E501 line too long (88 > 79 characters)
Line 92:80: E501 line too long (85 > 79 characters)
Line 98:80: E501 line too long (82 > 79 characters)

Line 29:9: E128 continuation line under-indented for visual indent
Line 30:9: E128 continuation line under-indented for visual indent
Line 33:1: E302 expected 2 blank lines, found 1
Line 40:9: E128 continuation line under-indented for visual indent
Line 41:9: E128 continuation line under-indented for visual indent
Line 42:23: W292 no newline at end of file

Comment last updated at 2024-03-20 17:08:21 UTC

@frheault frheault changed the title Compare tractograms (TODI, TDI, ACC) WIP - Compare tractograms (TODI, TDI, ACC) Oct 23, 2023
@arnaudbore arnaudbore self-requested a review October 23, 2023 13:53
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

1 similar comment
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore arnaudbore changed the title WIP - Compare tractograms (TODI, TDI, ACC) [WIP - Compare tractograms (TODI, TDI, ACC) Nov 2, 2023
@arnaudbore arnaudbore changed the title [WIP - Compare tractograms (TODI, TDI, ACC) [WIP] Compare tractograms (TODI, TDI, ACC) Nov 2, 2023
@arnaudbore arnaudbore added the WIP Work In Progress label Nov 2, 2023
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@frheault frheault changed the title [WIP] Compare tractograms (TODI, TDI, ACC) Compare tractograms (TODI, TDI, ACC) Dec 18, 2023
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

1 similar comment
@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

@arnaudbore
Copy link
Contributor

Build passed ! Good Job 🍻 !

Copy link
Contributor

@arnaudbore arnaudbore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of things to fix but otherwise GTG - fix pep8

scilpy/image/volume_operations.py Show resolved Hide resolved
@@ -388,3 +389,34 @@ def smooth_line_spline(streamline, smoothing_parameter, nb_ctrl_points):
smoothed_streamline[-1] = streamline[-1]

return smoothed_streamline


def generate_matched_points(sft):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

is_header_compatible_multiple_files,
load_tractogram_with_reference,
validate_nbr_processes)
from scilpy.tractograms.tractogram_operations import tractogram_pairwise_comparison
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like scilpy.tractanalysis.reproducibility_measures it seems to fit our needs here. We'll see in the future if we need to create scilpy.tractograms.reproducibility_measures or scilpy.bundles.reproducibility_measures

scripts/scil_tractogram_pairwise_comparison.py Outdated Show resolved Hide resolved
help='Optional input mask.')
p.add_argument('--skip_streamlines_distance', action='store_true',
help='Skip computation of the spatial distance between '
'streamlines.')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@frheault a quick sentence here please.

if args.out_prefix and args.out_prefix[-1] == '_':
args.out_prefix = args.out_prefix[:-1]
out_corr_filename = os.path.join(args.out_dir,
'{}_correlation.nii.gz'.format(args.out_prefix))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good enough
image

List of the computed differences in the same order as the input voxel.
"""
global sft_1, sft_2, matched_points_1, matched_points_2, tree_1, tree_2, \
sh_data_1, sh_data_2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We keep it as it is.

Copy link
Contributor

@arnaudbore arnaudbore left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A quick comment and a pep8 fix then LGTM @EmmaRenauld or @karanphil if you have some time I would need a second review of this code. Thank you in advance

scilpy/tractograms/tests/test_tractogram_operations.py Outdated Show resolved Hide resolved
Copy link
Contributor

@EmmaRenauld EmmaRenauld left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!


def normalize_metric(metric, reverse=False):
"""
Normalize a metric array to a range between 0 and 1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could actually work with an array of any dimension. It does not have to be a volume. Ex, it is probably useful everytime we want to change the range of a colormap. Should we put it in utils? @arnaudbore

scilpy/tractanalysis/reproducibility_measures.py Outdated Show resolved Hide resolved
scilpy/tractanalysis/reproducibility_measures.py Outdated Show resolved Hide resolved
scilpy/tractanalysis/reproducibility_measures.py Outdated Show resolved Hide resolved
scilpy/tractanalysis/reproducibility_measures.py Outdated Show resolved Hide resolved
scilpy/tractograms/streamline_operations.py Outdated Show resolved Hide resolved
scilpy/tractograms/streamline_operations.py Outdated Show resolved Hide resolved
scilpy/tractograms/streamline_operations.py Outdated Show resolved Hide resolved
@arnaudbore arnaudbore merged commit 234b88c into scilus:master Mar 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement WIP Work In Progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants